# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=libavif
pkgver=0.10.1
pkgrel=0
pkgdesc="Library for encoding and decoding .avif files"
url="https://aomediacodec.github.io/av1-avif/"
arch="all"
license="BSD-2-Clause"
makedepends="
	aom-dev
	cmake
	dav1d-dev
	libjpeg-turbo-dev
	libpng-dev
	samurai
	zlib-dev
	"
subpackages="$pkgname-dev $pkgname-apps"
source="https://github.com/AOMediaCodec/libavif/archive/v$pkgver/libavif-v$pkgver.tar.gz"
case $CARCH in
	s390x)
		# core dump https://github.com/AOMediaCodec/libavif/issues/731
		options="!check"
		;;
esac

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DAVIF_BUILD_APPS=ON \
		-DAVIF_BUILD_TESTS=ON \
		-DAVIF_CODEC_AOM=ON \
		-DAVIF_CODEC_DAV1D=ON
	cmake --build build
}

check() {
	# cmake --build build --target avif_test_all

	# https://github.com/AOMediaCodec/libavif/issues/800
	cd "$builddir"/build
	./tests/aviftest ../tests/data --io-only
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

apps() {
	amove usr/bin
}

sha512sums="
2f6f248c56c983761149d3c201fc2a2ea5072a32516578a7fdb2c66e3cd22491540f400e23581f873b15454250eeec8d433924ae2c1de9371b7924a5d82bef6b  libavif-v0.10.1.tar.gz
"
